<?php

/**
 * \file
 * Classe `Section`.
 */

namespace pilar\Forms /* \cond */ ; /* \endcond */
{

/**
 * Section d'un formulaire.
 *
 * \since 01/12/2008
 * \author Matthieu OVIEDO <matthieu.oviedo@gmail.com>
 */
class Section extends \object implements Atom {

/**
 * Sous-membres de formulaire.
 *
 * \since 01/12/2008
 */
private $_members = array();


protected function loadDefaultParams() {
 parent::loadDefaultParams();

 $this->params->define(array(
  'label' => '' // Libellé.
 ));
}


public function onParentFormChanged(Form $f) {
 foreach($this->_members as $m) {
  $m->onParentFormChanged($f);
 }
}


public function subMembers() {
 return $this->_members;
}


public function domNode($domDoc) {
 $domSection = $domDoc->createElement('section');

 $domSection->setAttribute('label', $this->get('label'));

 foreach($this->_members as $member) {
  $domSection->appendChild($member->domNode($domDoc));
 }

 return $domSection;
}


/**
 * Ajoute un membre à la suite.
 *
 * \param $m Membre à ajouter.
 *
 * \since 01/12/2008
 */
public function appendMember(Member $m) {
 $this->_members[] = $m;
}


/**
 * Ajoute un ou plusieurs membres à la suite.
 *
 * \param $ Membres à ajouter.
 *
 * \since 02/12/2008
 */
public function appendMembers() {
 foreach(func_get_args() as $a) {
  $this->appendMember($a);
 }
}


} // Class.

} // Namespace.

?>
